Title: Disable the Contact form module by Jetpack, conditionally, in WooCommerce

Publish Date: Sat, 02 Apr 2016 07:00:07 +0000

Categories: Uncategorized

Content:

Are you using [ablank href="https://jetpack.com/"]Jetpack[/ablank] on your website? I do, and if you are not, you should!

It is a plugin by [ablank href="https://automattic.com"]Automattic[/ablank] which boosts your website with many [ablank href="https://wordpress.com"]WordPress.com[/ablank] features, like markdown support, contact forms, subscriptions (to the blog), related posts, and [ablank href="https://jetpack.com/features/"]many others[/ablank].

I want to show you a single module in this article, the Contact form module. It adds the ability for who has access to the Dashboard to add contact forms to posts, and recently to products in [ablank href="https://www.woothemes.com/woocommerce/"]WooCommerce[/ablank].



When enabling this module, you will see a button like this on products, before the content editors:



This is cool, you can use the contact form to create a Product enquiry form, or something else, but you might not want the button to be available for everyone. The problem occurs when using plugins who give access to manage products like [ablank href="https://www.woothemes.com/products/product-vendors/" nofollow="true"]WooCommerce Product Vendors[/ablank].

Product Vendors allows vendor admins to log in the Dashboard to manage products. They will see, by default, the contact form button as well. How to disable it?

With a snippet, obvious no?

Add this code at the end of the file functions.php in wp-content/themes/your-child-theme-name/:

https://gist.github.com/SiR-DanieL/7fab36c684324685c757ea69af6c100c

Notice on line 3 I use the capability manage_woocommerce to allow only administrators and shop managers to see the button. If you want it to be available only to administrators, change it to manage_options.
